package com.neusoft.controller;

import com.neusoft.pojo.SysEmployee;
import com.neusoft.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/employee")
@CrossOrigin
public class EmployeeController {

    @Autowired
    EmployeeService employeeService;

    @RequestMapping("list") // 查询所有员工信息
    public List<SysEmployee> list() {
        return employeeService.list();
    }
    @RequestMapping("search") // 根据条件搜索员工信息
    public List<SysEmployee> searchList(@RequestParam String name, String status, String dept) {
        return employeeService.searchList(name, status, dept);
    }
    @RequestMapping("searchbyname") // 根据姓名搜索待入职员工信息
    public List<SysEmployee> searchByName(@RequestParam String name, String status) {
        return employeeService.searchByName(name, status);
    }
    @RequestMapping("searchbyistry") // 根据姓名搜索待入职员工信息
    public List<SysEmployee> searchByIsTry(@RequestParam String name) {
        return employeeService.searchByIsTry(name);
    }
    @RequestMapping("depts") // 查询所有部门的名称
    public List<String> getDepts() {
        return employeeService.depts();
    }
    @RequestMapping("delete") // 删除员工信息【本质上是修改visibility】
    public void deleteEmployee(@RequestParam String[] delArr) {
//        System.out.println(delArr);
        employeeService.deleteEmployee(delArr);
    }
    @RequestMapping("insert") // 添加员工
    public void addEmployee(SysEmployee emp) {
//        System.out.println(emp.toString());
        employeeService.addEmployee(emp);
    }
    @RequestMapping("update") // 编辑员工信息
    public void UpdateEmployee(SysEmployee info) {
        System.out.println(info.toString());
        employeeService.updateEmployee(info);
    }
    @RequestMapping("waitinglist") // 查询所有员工信息
    public List<SysEmployee> waitingList() {
        return employeeService.waitingList();
    }
    @RequestMapping("insertwaiting") // 添加待入职信息
    public void insertWaitingEmployee(SysEmployee waitingEmployee) {
        employeeService.insertWaitingEmployee(waitingEmployee);
    }
    @RequestMapping("handleinduction") // 办理入职
    public void handleInduction(String[] inductions, String status, String entryDate) {
        employeeService.handleInduction(inductions, status, entryDate);
    }
    @RequestMapping("updateprobation") // 编辑待入职员工信息
    public void updateProbation(SysEmployee info) {
        employeeService.updateProbation(info);
    }
    @RequestMapping("updateinduction") // 编辑待入职员工信息
    public void updateInduction(SysEmployee info) {
        employeeService.updateInduction(info);
    }
    @RequestMapping("quit") // 离职处理
    public void quit(String[] quitIds) {
        employeeService.quit(quitIds);
    }
    @RequestMapping("handlebecomefull") // 转正
    public void becomeFullMember(String[] becomeFulls, String formalDate) {
        employeeService.becomeFullMember(becomeFulls, formalDate);
    }
    @RequestMapping("singlequit") // 办理入职
    public void singleQuit(String workerId) {
        employeeService.singleQuit(workerId);
    }
    @RequestMapping("updatedeptorpost") // 编辑员工信息
    public void updateDeptOrPost(String dept, String post, String workerId) {
        employeeService.updateDeptOrPost(dept, post, workerId);
    }
}

